package com.lishe.lishe.lishe.module.main.activity;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.lishe.lishe.R;
import com.lishe.lishe.lishe.module.excitation.fragment.ExcitationFragment;
import com.lishe.lishe.lishe.module.mall.activity.ClassifyFragment;
import com.lishe.lishe.lishe.module.mall.fragment.IndexFragment;
import com.lishe.lishe.lishe.module.me.fragments.MineFragment;
import com.lishe.lishe.lishe.module.shopingcart.fragment.ShopCarFragment;

public class DataGenerator {

    public static final int []mTabRes = new int[]{
            R.drawable.tab_home_selector,
            R.drawable.tab_classify_selector,
            R.drawable.tab_company_selector,
            R.drawable.tab_shopcar_selector,
            R.drawable.tab_mine_selector};
    public static final int []mTabResPressed = new int[]{
            R.mipmap.tab_home_select,
            R.mipmap.tab_classify_select,
            R.mipmap.tab_company_select,
            R.mipmap.tab_shop_select,
            R.mipmap.tab_me_select};
    public static final String []mTabTitle = new String[]{"首页", "分类", "企业圈", "购物车", "我的"};

    private static TextView mGoodsCount;

    public static Fragment[] getFragments(){
        Fragment fragments[] = new Fragment[5];
        fragments[0] = IndexFragment.getInstance();
        fragments[1] = ClassifyFragment.getInstance();
        fragments[2] = ExcitationFragment.getInstance();
        fragments[3] = ShopCarFragment.getInstance();
        fragments[4] = MineFragment.getInstance();
        return fragments;
    }
 
    /**
     * 获取Tab 显示的内容
     * @param context
     * @param position
     * @return
     */
    public static View getTabView(Context context, int position){
        View view = LayoutInflater.from(context).inflate(R.layout.home_tab_content,null);
        ImageView tabIcon = view.findViewById(R.id.tab_content_image);
        tabIcon.setImageResource(DataGenerator.mTabRes[position]);
        TextView tabText = view.findViewById(R.id.tab_content_text);
        tabText.setText(mTabTitle[position]);
        if (position == 3) {
            mGoodsCount = view.findViewById(R.id.goods_count);
        }
        return view;
    }

    public static TextView getTvGoodsCount() {
        return mGoodsCount;
    }

}